<?php

use bedezign\yii2\audit\models\AuditErrorSearch;
use common\widgets\Box;
use common\widgets\GridView;
use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $searchModel AuditErrorSearch */

$this->title = Yii::t('audit', 'Errors');
$this->params['breadcrumbs'][] = ['label' => Yii::t('audit', 'Audit'), 'url' => ['default/index']];
$this->params['breadcrumbs'][] = $this->title;

$gridId = 'audit-error-index';
$gridConfig = [
    'id' => $gridId,
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        [
            'attribute' => 'id',
            'options' => [
                'width' => '80px',
            ],
        ],
        [
            'attribute' => 'entry_id',
            'class' => 'yii\grid\DataColumn',
            'value' => function ($data) {
                return $data->entry_id ? Html::a($data->entry_id, ['entry/view', 'id' => $data->entry_id]) : '';
            },
            'format' => 'raw',
        ],
        [
            'filter' => AuditErrorSearch::messageFilter(),
            'attribute' => 'message',
        ],
        [
            'attribute' => 'code',
            'options' => [
                'width' => '80px',
            ],
        ],
        [
            'filter' => AuditErrorSearch::fileFilter(),
            'attribute' => 'file',
        ],
        [
            'attribute' => 'line',
            'options' => [
                'width' => '80px',
            ],
        ],
        [
            'attribute' => 'hash',
            'options' => [
                'width' => '100px',
            ],
        ],
        [
            'attribute' => 'created',
            'options' => ['width' => '150px'],
        ],
        ['class' => 'yii\grid\ActionColumn', 'template' => '{view}'],
    ],
];

$boxButtons = $actions = [];
$showActions = false;

$boxButtons = !empty($boxButtons) ? implode(' ', $boxButtons) : null;

?>

<div class="row">
    <div class="col-xs-12">
        <?php Box::begin([
            'title' => $this->title,
            'bodyOptions' => [
                'class' => 'table-responsive'
            ],
            'buttonsTemplate' => $boxButtons,
            'grid' => $gridId,
        ]); ?>
        <?php echo GridView::widget($gridConfig); ?>

        <?php Box::end(); ?>
    </div>
</div>
